<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>/net/nas/exports/srv/www/webapps/Projects/Java/CS222/Seminar_2/AssignmentTwo/src/PartA.java.html</title>
<meta name="Generator" content="Vim/7.1">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#ffffff" text="#000000"><font face="monospace">
<font color="#0000ff">/**</font><br>
<font color="#0000ff">&nbsp;*</font><font color="#6a5acd">&nbsp;PartA.java</font><br>
<font color="#0000ff">&nbsp;*</font><font color="#6a5acd">&nbsp;</font><br>
<font color="#0000ff">&nbsp;*</font><font color="#6a5acd">&nbsp;Write a program that will:</font><br>
<font color="#0000ff">&nbsp;*</font><font color="#6a5acd">&nbsp;&nbsp; print “x must be 3” if the value of x is 3</font><br>
<font color="#0000ff">&nbsp;*</font><font color="#6a5acd">&nbsp;&nbsp; print “x is NOT 3” , if the value of x is greater than 3</font><br>
<font color="#0000ff">&nbsp;*</font><font color="#6a5acd">&nbsp;&nbsp; print “This runs no matter what”, always.</font><br>
<font color="#0000ff">&nbsp;*&nbsp;&nbsp; Ensure that each statement is printed on a separate line</font><br>
<font color="#0000ff">&nbsp;*&nbsp;&nbsp; Use the switch/case/default statement</font><br>
<font color="#0000ff">&nbsp;*&nbsp;&nbsp; Code the value of x in the program itself</font><br>
<font color="#0000ff">&nbsp;*</font><br>
<font color="#0000ff">&nbsp;* </font><font color="#6a5acd">@author</font><font color="#0000ff">: John Thomason</font><br>
<font color="#0000ff">&nbsp;*&nbsp;&nbsp;&nbsp;&nbsp;Date: Nov 13, 2008 / 7:16:47 AM</font><br>
<font color="#0000ff">&nbsp;*&nbsp;&nbsp; Class: CS222 Java Programming II</font><br>
<font color="#0000ff">&nbsp;*/</font><br>
<br>
<br>
<font color="#0000ff">/**</font><br>
<font color="#0000ff">&nbsp;*</font><font color="#6a5acd">&nbsp;PartA Class</font><br>
<font color="#6a5acd">&nbsp;</font><font color="#0000ff">*/</font><br>
<font color="#2e8b57"><b>public</b></font>&nbsp;<font color="#2e8b57"><b>class</b></font>&nbsp;PartA {<br>
<br>
&nbsp;&nbsp;<font color="#0000ff">/**</font><br>
<font color="#0000ff">&nbsp;&nbsp; *</font><font color="#6a5acd">&nbsp;Application Entry Point</font><br>
<font color="#0000ff">&nbsp;&nbsp; </font><font color="#0000ff">* </font><font color="#6a5acd">@param</font><font color="#008b8b">&nbsp;args</font><font color="#0000ff">&nbsp;The command line arguments</font><br>
<font color="#0000ff">&nbsp;&nbsp; */</font><br>
&nbsp;&nbsp;<font color="#2e8b57"><b>public</b></font>&nbsp;<font color="#2e8b57"><b>static</b></font>&nbsp;<font color="#2e8b57"><b>void</b></font>&nbsp;main(String[]&nbsp;args)&nbsp;{<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">//Local Var</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;Integer x = <font color="#ff00ff">3</font>;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">//Required Switch</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>switch</b></font>(x){<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>case</b></font>&nbsp;<font color="#ff00ff">3</font>:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prt(<font color="#ff00ff">&quot;x must be 3</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a52a2a"><b>break</b></font>;<br>
<font color="#a52a2a"><b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</b></font><font color="#a52a2a"><b>default</b></font>:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;prt(<font color="#ff00ff">&quot;x is NOT 3</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;}<font color="#0000ff">//switch()</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">//Always print this message</font><br>
&nbsp;&nbsp;&nbsp;&nbsp;prt(<font color="#ff00ff">&quot;This runs no matter what</font><font color="#6a5acd">\n</font><font color="#ff00ff">&quot;</font>);<br>
&nbsp;&nbsp;&nbsp;&nbsp;<br>
&nbsp;&nbsp;}<font color="#0000ff">//main()</font><br>
&nbsp;&nbsp;<br>
&nbsp;&nbsp;<font color="#0000ff">/**</font><br>
<font color="#0000ff">&nbsp;&nbsp; *</font><font color="#6a5acd">&nbsp;The the formatted message string</font><br>
<font color="#0000ff">&nbsp;&nbsp; </font><font color="#0000ff">* </font><font color="#6a5acd">@param</font><font color="#008b8b">&nbsp;msg</font><font color="#0000ff">&nbsp;The formatted message string to print</font><br>
<font color="#0000ff">&nbsp;&nbsp; */</font><br>
&nbsp;&nbsp;<font color="#2e8b57"><b>public</b></font>&nbsp;<font color="#2e8b57"><b>static</b></font>&nbsp;<font color="#2e8b57"><b>void</b></font>&nbsp;prt(String msg){<br>
&nbsp;&nbsp;&nbsp;&nbsp;System.out.print(msg);<br>
&nbsp;&nbsp;}<font color="#0000ff">//prt()</font><br>
<br>
}<font color="#0000ff">//end PartA class</font><br>
</font></body>
</html>
